// 计算fontsize
(function (doc, win) {
    var docEl = doc.documentElement,
        resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
        recalc = function () {
            var clientWidth = docEl.clientWidth;
            if (!clientWidth) return;
            if(clientWidth>=750){
                docEl.style.fontSize = '100px';
            }else{
                docEl.style.fontSize = 100 * (clientWidth / 750) + 'px';
            }
        };

    if (!doc.addEventListener) return;
    win.addEventListener(resizeEvt, recalc, false);
    doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);
// 新媒体/直播列表页切换
$(function(){
    $('.live-data-box').hide();
    $('.data-item').click(function(){
        $(this).addClass('active')
        $(this).siblings().removeClass('active')
        switch($(this).index()){
            case 0 : $('.media-data-box').show();$('.live-data-box').hide();break;
            case 1 : $('.media-data-box').hide();$('.live-data-box').show();break;
        }
    })
    // 返回
    $('.mui-action-back').click(function(){
        window.history.back(-1); 
    })
})
// 菜单
$(function(){
    var homePath =  './images/tarbar/icon_home.png'
    var homeSelectPath =  './images/tarbar/icon_home_select.png'
    var dataPath =  './images/tarbar/icon_data.png'
    var dataSelectPath =  './images/tarbar/icon_data_select.png'
    var tongjiPath =  './images/tarbar/icon_tongji.png'
    var tongjiSelectPath =  './images/tarbar/icon_tongji_select.png'
    var userPath =  './images/tarbar/icon_user.png'
    var userSelectPath =  './images/tarbar/icon_user_select.png'
    $('.tab-bar-item').click(function(){
        $(this).addClass('active')
        $(this).siblings().removeClass('active')
        switch($(this).index()){
            case 0:
                $(this).find('img').attr('src',homeSelectPath);
                $('.tab-bar-item:nth-child(2)').find('img').attr('src',dataPath);
                $('.tab-bar-item:nth-child(3)').find('img').attr('src',tongjiPath);
                $('.tab-bar-item:nth-child(4)').find('img').attr('src',userPath);
            break;
            case 1:

                $('.tab-bar-item:nth-child(1)').find('img').attr('src',homePath);
                $(this).find('img').attr('src',dataSelectPath);
                $('.tab-bar-item:nth-child(3)').find('img').attr('src',tongjiPath);
                $('.tab-bar-item:nth-child(4)').find('img').attr('src',userPath);
            break;
            case 2:
                $('.tab-bar-item:nth-child(1)').find('img').attr('src',homePath);
                $('.tab-bar-item:nth-child(2)').find('img').attr('src',dataPath);
                $(this).find('img').attr('src',tongjiSelectPath);
                $('.tab-bar-item:nth-child(4)').find('img').attr('src',userPath);
            break;
            case 3:
                $('.tab-bar-item:nth-child(1)').find('img').attr('src',homePath);
                $('.tab-bar-item:nth-child(2)').find('img').attr('src',dataPath);
                $('.tab-bar-item:nth-child(3)').find('img').attr('src',tongjiPath);
                $(this).find('img').attr('src',userSelectPath);
            break;
        }
    })
})